package com.xtravel.discovery.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.xtravel.R;

/**
 * Created by Memory on 15/11/9.
 */
public class LiveReplayMarkView extends RelativeLayout {
    private Context context;
    private LinearLayout replayPanel;
    private TextView markTextView;
    private TextView liveDurationTextView;
    private ImageButton liveMarkImage;

    public LiveReplayMarkView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        initControl();
    }

    public LiveReplayMarkView(Context context) {
        super(context);
        this.context = context;
        initControl();
    }

    private void initControl(){
        LayoutInflater inflater = LayoutInflater.from(this.context);
        View view = inflater.inflate(R.layout.live_replay_mark_layout, null);
        replayPanel = (LinearLayout)view.findViewById(R.id.replay_panel);
        markTextView = (TextView)view.findViewById(R.id.live_mark_title);
        liveMarkImage = (ImageButton)view.findViewById(R.id.live_mark_img);
        liveDurationTextView = (TextView)view.findViewById(R.id.live_duration_textview);
        this.addView(view);
    }

    public void setText(boolean isLive, String duration)
    {
        if(isLive)
        {
            replayPanel.setVisibility(GONE);
            markTextView.setText("LIVE 直播");
            liveMarkImage.setImageResource(R.mipmap.ic_tag_live_orange);
        }
        else
        {
            replayPanel.setVisibility(GONE);
            markTextView.setText(duration);
            liveMarkImage.setImageResource(R.mipmap.ic_tag_live_blue);
            //liveDurationTextView.setText(duration);
        }
    }
}
